Rsqrt
逐元素计算输入数据的平方根倒数(Reciprocal Square Root)。
\[\text{dst}_i = \frac{1}{\sqrt{\text{src}_i}}\]
对于输入 src 中的每个元素,计算其平方根的倒数。
- 输入:
src - 输入数据地址。
length - 计算长度(对于复数类型,指复数的个数)。
core_mask - 核掩码(仅共享存储版本需要)。
- 输出:
dst - 计算结果地址,其大小与 src 相同。
- 支持平台:
FT78NEMT7004
备注
FT78NE 支持fp32, int8, int16, int32, fp64, cplx64, cplx128
MT7004 支持fp16, fp32, int16, int32, cplx64
共享存储版本:
-
void i8_rsqrt_s(int8_t *src, float *dst, int length, int core_mask)
-
void i16_rsqrt_s(int16_t *src, float *dst, int length, int core_mask)
-
void i32_rsqrt_s(int32_t *src, float *dst, int length, int core_mask)
-
void hp_rsqrt_s(half *src, half *dst, int length, int core_mask)
-
void fp_rsqrt_s(float *src, float *dst, int length, int core_mask)
-
void dp_rsqrt_s(double *src, double *dst, int length, int core_mask)
-
void c64_rsqrt_s(float *src, float *dst, int length, int core_mask)
-
void c128_rsqrt_s(double *src, double *dst, int length, int core_mask)
C调用示例:
1//FT78NE示例
2#include <stdio.h>
3#include <rsqrt.h>
4
5int main(int argc, char* argv[]) {
6 float *src = (float *)0xA0000000; // input在DDR空间
7 float *dst = (float *)0xB0000000; // output
8 int length = 1000;
9 int core_mask = 0xff;
10 fp_rsqrt_s(src, dst, length, core_mask);
11 return 0;
12}
私有存储版本:
-
void i8_rsqrt_p(int8_t *src, float *dst, int length)
-
void i16_rsqrt_p(int16_t *src, float *dst, int length)
-
void i32_rsqrt_p(int32_t *src, float *dst, int length)
-
void hp_rsqrt_p(half *src, half *dst, int length)
-
void fp_rsqrt_p(float *src, float *dst, int length)
-
void dp_rsqrt_p(double *src, double *dst, int length)
-
void c64_rsqrt_p(float *src, float *dst, int length)
-
void c128_rsqrt_p(double *src, double *dst, int length)
C调用示例:
1//FT78NE示例
2#include <stdio.h>
3#include <rsqrt.h>
4
5int main(int argc, char* argv[]) {
6 float *src = (float *)0x10000000; // input在L2空间
7 float *dst = (float *)0x10001000; // output
8 int length = 1000;
9 fp_rsqrt_p(src, dst, length);
10 return 0;
11}